import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Test17 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int sum = 0;
        int []array = new int[m+1];
        //将这个数组的每一个元素都置为max
        for(int i = 0; i < m+1; i++){
            array[i] = Integer.MAX_VALUE;
        }
        array[n] = 0;
        for(int i = n;i<=m; i++){
            //如果为默认值的话,说明不经过这里,直接
            if(array[i] == Integer.MAX_VALUE){
                continue;
            }
            //获取i的约数
            PriorityQueue<Integer> list = func(i);
            for(int j:list){
                sum++;

                if(array[m] != Integer.MAX_VALUE){
                    System.out.println(array[m]);
                    System.out.println(sum);
                    return;
                }
                if(i+j<=m&&array[i+j] == Integer.MAX_VALUE){
                    array[i+j] = array[i]+1;
                }else if(i+j<=m&&array[i+j] != Integer.MAX_VALUE){
                    array[i+j] = Math.min(array[i+j],array[i]+1);
                }

            }
        }
        System.out.println(-1);


        System.out.println(sum);

    }

    public static PriorityQueue<Integer> func(int num){
        PriorityQueue<Integer> list = new PriorityQueue<>();
        for(int i = 2; i <= Math.sqrt(num) ;i++){
            if(num % i == 0){
                //如果num%i==0说明i是num的约数
                list.add(i);
                if(i != num/i){
                    list.add(num/i);
                }
            }
        }
        return list;

    }
}
